package com.wnzt.baszh.controller;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wnzt.baszh.entity.Tsysuser;
import com.wnzt.baszh.util.common.BaseController;
import com.wnzt.baszh.util.common.ConstantsUtils;
import com.wnzt.baszh.util.common.FileEncodeAndDecode;
import com.wnzt.baszh.util.common.GetLanIp;
import com.wnzt.baszh.util.common.GlobalStatic;
import com.wnzt.baszh.service.ISystemMaintenService;
import com.wnzt.baszh.util.common.PageHelper;
import com.wnzt.baszh.util.common.encode;

/**
 * 用户管理和维护控制器类
 */
@Controller
@RequestMapping("/systemMaintenance")
public class SystemMaintenController extends BaseController{
	
	@Autowired
	private ISystemMaintenService systemMaintenService;
	/**
	 *跳转图片分类模板维护页面 
	 */
	@RequestMapping("/ImageTempMaintenance")
	public String ImageTempMaintenance(){
		return "systemMaintenance/ImageTempMaintenance";
	}
	
	/**
	 *跳转用户管理页面 
	 */
	@RequestMapping("/user")
	public String UserManagement(){
		return "systemMaintenance/user";
	}
	
	/**
	 *用户组管理页面 
	 */
	@RequestMapping("/userGroup")
	public String userGroup(){
		return "systemMaintenance/userGroup";
	}
	
	/**
	 *角色管理设置页面 
	 */
	@RequestMapping("/role")
	public String MenuPermissionSetting(){
		return "systemMaintenance/role";
	}
	
	/**
	 *角色管理设置页面 
	 */
	@RequestMapping("/menu")
	public String menu(){
		return "systemMaintenance/menu";
	}
	
	/**
	 *跳转水印设置页面 
	 */
	@RequestMapping("/WatermarkSetting")
	public String WatermarkSetting(){
		return "systemMaintenance/WatermarkSetting";
	}
	
	/**
	 *跳转水印设置页面 
	 */
	@RequestMapping("/ConfigureAuditors")
	public String ConfigureAuditors(){
		return "systemMaintenance/ConfigureAuditors";
	}
	
	/**
	 *跳转用户访问权限设置界面
	 */
	@RequestMapping("/AccessPermisionSettings")
	public String AccessPermisionSettings(){
		return "systemMaintenance/AccessPermisionSettings";
	}
	
	/**
	 *跳转用户浏览权限页面
	 */
	@RequestMapping("/UserAccessRightSettings")
	public String UserAccessRightSettings(){
		return "systemMaintenance/UserAccessRightSettings";
	}
	
	/**
	 *跳转借阅目的管理页面
	 */
	@RequestMapping("/BorrowPurposeManage")
	public String BorrowPurposeManage(){
		return "systemMaintenance/BorrowPurposeManage";
	}
	
	/**
	 *跳转个性化病案浏览设置界面
	 */
	@RequestMapping("/PersonalizedBrowSetting")
	public String PersonalizedBrowSetting(){
		return "systemMaintenance/PersonalizedBrowSetting";
	}
	
	/**
     *
     */
    @RequestMapping("/rotate")
    public String rotate(){
        return "systemMaintenance/rotate";
    }
	
	/**
	 * 加载所有图片分类支援
	 */
	@RequestMapping("getImageTempMainData")
	@ResponseBody
	public PageHelper getImageTempMainData(HttpServletRequest request){
        int page = Integer.valueOf(request.getParameter("page"));
		int rows = Integer.valueOf(request.getParameter("rows"));
		PageHelper paHelper = systemMaintenService.getImageTempMainData(page,rows);
		return paHelper;
	}

	/**
	 * 添加图片分类模板
	 */
	@RequestMapping("AddImageTempMain")
	@ResponseBody
	public Object AddImageTempMain(HttpServletRequest request){
		String FCODE = request.getParameter("FCODE");//图片分类模板编码
		String FNAME = request.getParameter("FNAME");//图片分类模板名称
		String FTYPE = request.getParameter("FTYPE");//图片分类模板助记词
		String FPX = request.getParameter("FPX");//图片分类模板排序
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("FCODE", FCODE);
		map.put("FNAME", FNAME);
		map.put("FTYPE", FTYPE);
		map.put("FPX", FPX);
		
		Integer uuid = this.systemMaintenService.AddImageTempMain(map);
		if (uuid != null) return true;
		return false;
	}
	
	/**
	 * 修改图片分类模板
	 */
	@RequestMapping("EditImageTempMain")
	@ResponseBody
	public Object EditImageTempMain(HttpServletRequest request){
		
		boolean flag=true;
		String FCODE = request.getParameter("FCODE");//图片分类模板编码
		String FNAME = request.getParameter("FNAME");//图片分类模板名称
		String FTYPE = request.getParameter("FTYPE");//图片分类模板助记词
		String FPX = request.getParameter("FPX");//图片分类模板排序
		String FID = request.getParameter("FID");//图片分类模板id
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("FCODE", FCODE);
		map.put("FNAME", FNAME);
		map.put("FTYPE", FTYPE);
		map.put("FPX", FPX);
		map.put("FID", FID);
		
		this.systemMaintenService.EditImageTempMain(map);
		if (flag) return true;
		return false;
	}
	
	/**
	 * 删除图片分类模板
	 */
	@RequestMapping("DeleteImageTempMain")
	@ResponseBody
	public Object DeleteImageTempMain(HttpServletRequest request){
		
		boolean flag=true;
		String FID = request.getParameter("FID");//图片分类模板id
		this.systemMaintenService.DeleteImageTempMain(FID);
		if (flag) return true;
		return false;
	}
	
	/**
	 * 查询所有的图片分类模板，判断模板编号，模板名称和排序号是否唯一
	 */
	@SuppressWarnings("rawtypes")
	@RequestMapping("CheckAllImageTempMain")
	@ResponseBody
	public Object CheckAllImageTempMain(){
		List list = systemMaintenService.CheckAllImageTempMain();
		return list;
	}
	
	//保存水印
	@RequestMapping("SaveWatermark")
	@ResponseBody
	public Object SaveWatermark(HttpServletRequest request){
		String FNR = request.getParameter("FNR");//获取水印文字内容
		String angle = request.getParameter("angle");//获取水印方向
		String FYS = request.getParameter("color");//获取水印文字颜色
		String FZT = request.getParameter("FZT");//获取水印文字字体
		String FDX = request.getParameter("FDX");//获取水印文字大小
		String weight = request.getParameter("weight");//获取水印文字是否加粗
		String shadow = request.getParameter("shadow");//获取水印文字是否阴影
		String isuse = request.getParameter("isuse");//病案打印时是否需要该水印
		String alpa = request.getParameter("alpa");//获取水印文字透明度
		String FKD = request.getParameter("FKD");//获取水印文字宽度
		String FGD = request.getParameter("FGD");//获取水印文字高度
		String position = request.getParameter("position");//获取水印文字位置
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("FNR", FNR);
		map.put("angle", angle);
		map.put("FYS", FYS);
		map.put("FZT", FZT);
		map.put("FDX", FDX);
		map.put("weight", weight);
		map.put("shadow", shadow);
		map.put("isuse", isuse);
		map.put("alpa", alpa);
		map.put("FKD", FKD);
		map.put("FGD", FGD);
		map.put("position", position);
		Map<String, Object> reMap = systemMaintenService.SaveWatermark(map);
		return reMap;
	}
	
	//加载水印
	@RequestMapping("CheckWatermark")
	@ResponseBody
	public Object CheckWatermark(){
		return systemMaintenService.CheckWatermark();
	}
	
	/**
     * 按条件查询用户信息
     * @param request
     * @return 用户信息集合
     */
    @RequestMapping("/findUsers")
    @ResponseBody
    public PageHelper findUsers(HttpServletRequest request) {
    	String nameNum = request.getParameter("nameNum");  // 用户编号
        String name = request.getParameter("name");  // 用户名
        String department = request.getParameter("department");  // 默认科室
        String userGroup = request.getParameter("userGroup");  // 用户组
        String type = request.getParameter("type");  // 用户类型
        String casn = request.getParameter("casn");  // 用户类型
        String nameOrNum = request.getParameter("nameOrNum"); //配置审核人员界面需要(工号或者姓名)
        String isLimit = request.getParameter("isLimit");   //ip设置界面区分用户是否已经限制权限
        String page = request.getParameter("page");
        String rows = request.getParameter("rows");
        
        Map<String, Object> params = new HashMap<String, Object>();
        if (ConstantsUtils.isNotBank(name)) {
            try {
                name = URLDecoder.decode(name, "UTF-8");
                params.put("name", name);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        if (ConstantsUtils.isNotBank(nameNum)) {
            params.put("nameNum", nameNum);
        }
        if (ConstantsUtils.isNotBank(isLimit)) {
            params.put("isLimit", isLimit);
        }
        if (ConstantsUtils.isNotBank(department)) {
            params.put("department", department);
        }
        if (ConstantsUtils.isNotBank(userGroup)) {
            params.put("userGroup", userGroup);
        }
        if (ConstantsUtils.isNotBank(type)) {
            params.put("type", type);
        }
        if (ConstantsUtils.isNotBank(casn)) {
            params.put("casn", casn);
        }
        if (ConstantsUtils.isNotBank(nameOrNum)) {
            params.put("nameOrNum", nameOrNum);
        }
        if (ConstantsUtils.isNotBank(page)) {
            params.put("page", page);
        }
        if (ConstantsUtils.isNotBank(rows)) {
            params.put("rows", rows);
        }
        
        PageHelper pageHelper = systemMaintenService.findUsers(params);
        return pageHelper;
    }
    
    /**
     * 查询医院中医护人员姓名
     * @return  医护人员姓名集合
     */
    @RequestMapping("/findUsername")
    @ResponseBody
    public List<Map<String, Object>> findUserame() {
        List<Map<String, Object>> list = systemMaintenService.findUsername();
        return list;
    }
    
    /**
     * CA序列号
     * @return  医护人员ca集合
     */
    @RequestMapping("/findNetcaSN")
    @ResponseBody
    public List<Map<String, Object>> findNetcaSN() {
        List<Map<String, Object>> list = systemMaintenService.findNetcaSN();
        return list;
    }
    
    /**
     * 查询用户角色(用户组)
     * @return 角色集合
     */
    @RequestMapping("/findRoles")
    @ResponseBody
    public List<Map<String, Object>> findRoles() {
        List<Map<String, Object>> list = systemMaintenService.findRoles();
        return list;
    }
    
    /**
     * 查询医院科室
     * @return 科室集合
     */
    @RequestMapping("/findDepartments")
    @ResponseBody
    public List<Map<String, Object>> findDepartments() {
        List<Map<String, Object>> list = systemMaintenService.findDepartments();
        return list;
    }
    
    /**
     * 查询医院科室
     * @return 科室集合
     */
    @RequestMapping("/findDepartmentsWithoutQy")
    @ResponseBody
    public List<Map<String, Object>> findDepartmentsWithoutQy(HttpServletRequest request) {
        HttpSession session = request.getSession();
        Map<String, Object> params = new HashMap<String, Object>();
        Tsysuser loginUser = (Tsysuser) session.getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        params.put("fcode", loginUser.getFcode());
        params.put("fworkroom", loginUser.getFworkroom());
        List<Map<String, Object>> list = systemMaintenService.findDepartmentsWithoutQy(params);
        return list;
    }
    
    /**
     * 查询医院病区
     * @return 病区集合
     */
    @RequestMapping("/findBQ")
    @ResponseBody
    public List<Map<String, Object>> findBQ() {
        List<Map<String, Object>> list = systemMaintenService.findBQ();
        return list;
    }
    
    /**
     * 查询医院病案室内部分组
     * @return 分组集合
     */
    @RequestMapping("/findGroups")
    @ResponseBody
    public List<Map<String, Object>> findGroups() {
        List<Map<String, Object>> list = systemMaintenService.findGroups();
        return list;
    }
    
    /**
     * 添加用户
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/addUser", method = RequestMethod.POST)
    @ResponseBody
    public Object addUser(HttpServletRequest request) {
        String nameNum = request.getParameter("nameNum");  // 用户编号
        String casn = request.getParameter("casn");  // ca序列号
        String name = request.getParameter("name");  // 姓名 
        String role = request.getParameter("role");  // 角色
        String resName = request.getParameter("resName");  // 用户名
        String password = request.getParameter("password");  // 密码
        String userType = request.getParameter("userType");  // 是否病案室人员
        String departNum = request.getParameter("departNum");  // 科室编号
        String depart = request.getParameter("depart");  // 科室名
        String districtNum = request.getParameter("districtNum");  // 病区编号
        String district = request.getParameter("district");  // 病区
        String groupNum = request.getParameter("groupNum");  // 分组编号
        String group = request.getParameter("group");  // 分组名
        String phone = request.getParameter("phone");  // 手机号
        String workrooms = request.getParameter("workrooms");  // 工作科室
        String districts = request.getParameter("districts");  // 工作病区
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(nameNum)) {
            params.put("nameNum", nameNum);
        }
        if (ConstantsUtils.isNotBank(casn)) {
            params.put("casn", casn);
        }
        if (ConstantsUtils.isNotBank(name)) {
            params.put("name", name);
        }
        if (ConstantsUtils.isNotBank(role)) {
            params.put("role", role);
        }
        if (ConstantsUtils.isNotBank(resName)) {
            params.put("resName", resName);
        }
        if (ConstantsUtils.isNotBank(password)) {
            params.put("password", password);
        }
        if (ConstantsUtils.isNotBank(userType)) {
            params.put("userType", userType);
        }
        if (ConstantsUtils.isNotBank(departNum)) {
            params.put("departNum", departNum);
        }
        if (ConstantsUtils.isNotBank(depart)) {
            params.put("depart", depart);
        }
        if (ConstantsUtils.isNotBank(districtNum)) {
            params.put("districtNum", districtNum);
        }
        if (ConstantsUtils.isNotBank(district)) {
            params.put("district", district);
        }
        if (ConstantsUtils.isNotBank(groupNum)) {
            params.put("groupNum", groupNum);
        }
        if (ConstantsUtils.isNotBank(group)) {
            params.put("group", group);
        }
        if (ConstantsUtils.isNotBank(phone)) {
            params.put("phone", phone);
        }
        if (ConstantsUtils.isNotBank(workrooms)) {
            params.put("workrooms", workrooms);
        }
        if (ConstantsUtils.isNotBank(districts)) {
            params.put("districts", districts);
        }
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        try {
			systemMaintenService.addUser(params);
		} catch (Exception e) {
			e.printStackTrace();
			result.put("success", false);
			result.put("msg", e.getMessage());
		}
        return result;
    }
    
    /**
     * 修改用户
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/updateUser", method = RequestMethod.POST)
    @ResponseBody
    public Object updateUser(HttpServletRequest request) {
    	String id = request.getParameter("id");
        String nameNum = request.getParameter("nameNum");  // 用户编号
        String caSN = request.getParameter("caSN");  // ca序列号
        String name = request.getParameter("name");  // 姓名 
        String roleNum = request.getParameter("roleNum");  // 角色
        String resName = request.getParameter("resName");  // 用户名
        String password = request.getParameter("password");  // 密码
        String userType = request.getParameter("userType");  // 是否病案室人员
        String departNum = request.getParameter("departNum");  // 科室编号
        String depart = request.getParameter("depart");  // 科室名
        String districtNum = request.getParameter("districtNum");  // 病区编号
        String district = request.getParameter("district");  // 病区
        String groupNum = request.getParameter("groupNum");  // 分组编号
        String group = request.getParameter("group");  // 分组名
        String phone = request.getParameter("phone");  // 手机号
        String workrooms = request.getParameter("workrooms");  // 工作科室
        String districts = request.getParameter("districts");  // 工作病区
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(id)) {
            params.put("id", id);
        }
        if (ConstantsUtils.isNotBank(caSN)) {
            params.put("caSN", caSN);
        }
        if (ConstantsUtils.isNotBank(nameNum)) {
            params.put("nameNum", nameNum);
        }
        if (ConstantsUtils.isNotBank(name)) {
            params.put("name", name);
        }
        if (ConstantsUtils.isNotBank(roleNum)) {
            params.put("roleNum", roleNum);
        }
        if (ConstantsUtils.isNotBank(resName)) {
            params.put("resName", resName);
        }
        if (ConstantsUtils.isNotBank(password)) {
            params.put("password", password);
        }
        if (ConstantsUtils.isNotBank(userType)) {
            params.put("userType", userType);
        }
        if (ConstantsUtils.isNotBank(departNum)) {
            params.put("departNum", departNum);
        }
        if (ConstantsUtils.isNotBank(depart)) {
            params.put("depart", depart);
        }
        if (ConstantsUtils.isNotBank(districtNum)) {
            params.put("districtNum", districtNum);
        }
        if (ConstantsUtils.isNotBank(district)) {
            params.put("district", district);
        }
        if (ConstantsUtils.isNotBank(groupNum)) {
            params.put("groupNum", groupNum);
        }
        if (ConstantsUtils.isNotBank(group)) {
            params.put("group", group);
        }
        if (ConstantsUtils.isNotBank(phone)) {
            params.put("phone", phone);
        }
        if (ConstantsUtils.isNotBank(workrooms)) {
            params.put("workrooms", workrooms);
        }
        if (ConstantsUtils.isNotBank(districts)) {
            params.put("districts", districts);
        }
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        try {
			systemMaintenService.updateUser(params);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			result.put("success", false);
			result.put("msg", e.getMessage());
		}
        return result;
    }
    
    /**
     * 删除用户
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/deleteUser")
    @ResponseBody
    public Object deleteUser(HttpServletRequest request) {
        String idStr = request.getParameter("idStr");  // 用户信息序号
        systemMaintenService.deleteUser(idStr);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 查询用户角色与菜单模块对应关系
     * @return 角色的菜单模块集合
     */
    @RequestMapping("/findRoleList")
    @ResponseBody
    public List<Map<String, Object>> findRoleList() {
        List<Map<String, Object>> list = systemMaintenService.findRoleList();
        return list;
    }
    
    @RequestMapping("/findModulesBySys")
    @ResponseBody
    public List<Map<String, Object>> findModulesBySys(HttpServletRequest request) {
        String fsysflag = request.getParameter("fsysflag");
        List<Map<String, Object>> list = systemMaintenService.findModulesBySys(fsysflag);
        return list;
    }
    
    /**
     * 添加用户组
     * @param request
     * @return 操作结果
     */
    @RequestMapping("/addRole")
    @ResponseBody
    public Map<String, Object> addRole(HttpServletRequest request) {
        String roleNum = request.getParameter("roleNum");  // 角色编号
        String roleName = request.getParameter("roleName");  // 角色名
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(roleNum)) {
            params.put("roleNum", roleNum);
        }
        if (ConstantsUtils.isNotBank(roleName)) {
            params.put("roleName", roleName);
        }
        systemMaintenService.addRole(params);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 修改角色
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/updateRole")
    @ResponseBody
    public Object updateRole(HttpServletRequest request) {
        String id = request.getParameter("id");  // 用户信息序号
        String roleNum = request.getParameter("roleNum");  // 角色编号
        String roleName = request.getParameter("roleName");  // 角色名
        String childNodes = request.getParameter("childNodes");  // 菜单模块
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();
        // 保存模块菜单
        Map<String, Object> roleParams = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(id)) {
            params.put("id", id);
        }
        if (ConstantsUtils.isNotBank(roleNum)) {
            params.put("roleNum", roleNum);
            roleParams.put("role", roleNum);
        }
        if (ConstantsUtils.isNotBank(roleName)) {
            params.put("roleName", roleName);
        }
        if (ConstantsUtils.isNotBank(childNodes)) {
            roleParams.put("childNodes", childNodes);
        }
        systemMaintenService.updateRole(params, roleParams);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 删除角色
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/deleteRole")
    @ResponseBody
    public Object deleteRole(HttpServletRequest request) {
        String idStr = request.getParameter("idStr");  // 角色信息序号
        systemMaintenService.deleteRole(idStr);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 查询菜单列表
     * @param request
     * @return 菜单列表
     */
    @RequestMapping(value = "/findMenuListBySysAndModule")
    @ResponseBody
    public Object findMenuListBySysAndModule(HttpServletRequest request) {
        String fsysflag = request.getParameter("fsysflag"); // 系统标识   0: 病案系统， 1: 病案示踪系统
        String module =request.getParameter("module");
        // 查找菜单列表
        List<Map<String, Object>> menu = systemMaintenService.findMenuListBySysAndModule(fsysflag, module);
        
        List<Map<String, Object>> nodeList = new ArrayList<Map<String,Object>>();
        for (Map<String, Object> map : menu) {
        	String fatherCode = (String) map.get("ffather");  // 父节点编号
        	boolean fatherNode = (Boolean) map.get("fhavefather");   // 是否有父节点  true: 表示有父节点
        	boolean childNode = (Boolean) map.get("fhavechildren");  // 是否有子节点  true: 表示有子节点
        	
            // 当节点有子节点时，给节点添加子节点list列表，用来保存子节点
        	if (childNode) {
    			map.put("children", new ArrayList<Map<String, Object>>());
    		}
        	
        	if (!fatherNode) {  // 当节点没有父节点时，表示该节点是顶级节点，要将其加到节点列表中
        		nodeList.add(map);
        	} else {  // 当节点有父节点时, 表示其是子节点，找到该节点的父节点，将该节点添加到其父节点的子节点列表中
        		for (Map<String, Object> map2 : menu) {
        			String code = (String) map2.get("fcode");
        			if (fatherCode.equals(code)) {
        				@SuppressWarnings("unchecked")
						List<Map<String, Object>> childNodeList = (List<Map<String, Object>>) map2.get("children");
        				childNodeList.add(map);
        				break;
        			}
        		}
        	}
        }
        return nodeList;
    }
    
    /**
     * 查询菜单列表
     * @param request
     * @return 菜单列表
     */
    @RequestMapping(value = "/findMenuList")
    @ResponseBody
    public Object findMenuList(HttpServletRequest request) {
        String fsysflag = request.getParameter("fsysflag"); //系统标识
        List<Map<String, Object>> menu = systemMaintenService.findMenuList(fsysflag);
        List<Map<String, Object>> fatherNodeList = new ArrayList<Map<String,Object>>();   // 存放父节点(父节点中包含其子节点)
        for (Map<String, Object> map : menu) {
            // 获得该菜单节点的父节点
            String fatherNode = (String) map.get("ffather");
            // 判断父节点是否为空，若为空表示该节点为父节点
            if (ConstantsUtils.isBank(fatherNode)) {
                // 为父节点创建一个子节点list集合，用来存放该父节点的子节点
                map.put("children", new ArrayList<Map<String, Object>>());
                fatherNodeList.add(map);
            } else {  // 当父节点不为空时，表明该节点为子节点，将该子节点添加到对应的父节点中
                for (Map<String, Object> nodeMap : fatherNodeList) {
                    String nodeCode = (String) nodeMap.get("fcode");
                    if (nodeCode.equals(fatherNode)) {
                        @SuppressWarnings("unchecked")
                        List<Map<String, Object>> childNodeList = (List<Map<String, Object>>) nodeMap.get("children");
                        childNodeList.add(map);
                    }
                }
                
            }
        }
        return fatherNodeList;
    }
    
    /**
     * 按模块查询菜单
     * @param request 模块名
     * @return 模块对应菜单
     */
    @RequestMapping(value = "/findModuleMenus")
    @ResponseBody
    public Object findModuleMenus(HttpServletRequest request) {
        String module =request.getParameter("module");
        
        List<Map<String, Object>> list = systemMaintenService.findModuleMenus(module);
        return list;
    }
    
    /**
     * 添加模块
     * @param request
     * @return 操作结果
     */
    @RequestMapping("/addModule")
    @ResponseBody
    public Map<String, Object> addModule(HttpServletRequest request) {
        String fsysflag = request.getParameter("fsysflag"); //系统标识
        String moduleNum = request.getParameter("moduleNum");  // 模块编号
        String moduleName = request.getParameter("moduleName");  // 模块名
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();
        
        if (ConstantsUtils.isNotBank(fsysflag)) {
            params.put("fsysflag", fsysflag);
        }
        if (ConstantsUtils.isNotBank(moduleNum)) {
            params.put("moduleNum", moduleNum);
        }
        if (ConstantsUtils.isNotBank(moduleName)) {
            params.put("moduleName", moduleName);
        }
        systemMaintenService.addModule(params);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 修改模块
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/updateModule")
    @ResponseBody
    public Object updateModule(HttpServletRequest request) {
        String fsysflag = request.getParameter("fsysflag"); //系统标识
        String id = request.getParameter("id");  // 用户信息序号
        String moduleNum = request.getParameter("moduleNum");  // 模块编号
        String moduleName = request.getParameter("moduleName");  // 模块名
        String nodes = request.getParameter("nodes");  // 子菜单
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();
        // 保存模块菜单
        Map<String, Object> moduleParams = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(fsysflag)) {
            params.put("fsysflag", fsysflag);
            moduleParams.put("fsysflag", fsysflag);
        }
        if (ConstantsUtils.isNotBank(id)) {
            params.put("id", id);
        }
        if (ConstantsUtils.isNotBank(moduleNum)) {
            params.put("moduleNum", moduleNum);
            moduleParams.put("module", moduleNum);
        }
        if (ConstantsUtils.isNotBank(moduleName)) {
            params.put("moduleName", moduleName);
        }
        if (ConstantsUtils.isNotBank(nodes)) {
            moduleParams.put("nodes", nodes);
        }
        systemMaintenService.updateModule(params, moduleParams);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 删除模块
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/deleteModule")
    @ResponseBody
    public Object deleteModule(HttpServletRequest request) {
        String idStr = request.getParameter("idStr");  // 模块信息序号
        systemMaintenService.deleteModule(idStr);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 保存模块菜单
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/saveModuleMenu", method = RequestMethod.POST)
    @ResponseBody
    public Object saveModuleMenu(HttpServletRequest request) {
        String fsysflag = request.getParameter("fsysflag"); //系统标识
        String module = request.getParameter("module");  // 模块
        String nodes = request.getParameter("nodes");  // 菜单节点
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(fsysflag)) {
            params.put("fsysflag", fsysflag);
        }
        if (ConstantsUtils.isNotBank(module)) {
            params.put("module", module);
        }
        if (ConstantsUtils.isNotBank(nodes)) {
            params.put("nodes", nodes);
        }
        systemMaintenService.saveModuleMenu(params);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 修改用户密码
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
    @ResponseBody
    public Object updatePassword(HttpServletRequest request) {
        String id = request.getParameter("id");  // 用户id
        String newPsw = request.getParameter("newPsw");  // 新密码
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(id)) {
            params.put("id", id);
        }
        if (ConstantsUtils.isNotBank(newPsw)) {
            params.put("newPsw", newPsw);
        }
        systemMaintenService.updatePassword(params);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 查询模块列表
     * @param request
     * @return 模块列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/findModuleList")
    @ResponseBody
    public Object findModuleList(HttpServletRequest request) {
        String name = request.getParameter("name");  // 用户组名
        
        List<Map<String, Object>> modules = systemMaintenService.findModuleList(name);
        List<Map<String, Object>> systems = systemMaintenService.findSystems();   // 系统列表 
        
        // 将菜单模块添加到对应的系统列表中，fsysflag为系统标识
        for (Map<String, Object> module : modules) {
            String mark = (String) module.get("fsysflag");  // 模块中的系统名
            
            for (Map<String, Object> s : systems) {
                String num = (String) s.get("fsysflag");
                
                // 判断模块中保存的系统名是否与系统列表中的系统名相同
                if (mark.equals(num)) {
                    if (s.containsKey("children")) {
                        ((List<Map<String, Object>>)s.get("children")).add(module);
                    } else {
                        s.put("children", new ArrayList<Map<String, Object>>());
                        ((List<Map<String, Object>>)s.get("children")).add(module);
                    }
                }
            }
        }
        return systems;
    }
    
    /**
     * 保存角色模块
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/saveRoleModule", method = RequestMethod.POST)
    @ResponseBody
    public Object saveRoleModule(HttpServletRequest request) {
        String role = request.getParameter("role");  // 角色
        String childNodes = request.getParameter("childNodes");  // 子模块
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(role)) {
            params.put("role", role);
        }
        if (ConstantsUtils.isNotBank(childNodes)) {
            params.put("childNodes", childNodes);
        }
        systemMaintenService.saveRoleModule(params);
        
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }
    
    /**
     * 查询所有用户信息
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/getUsers", method = RequestMethod.GET)
    @ResponseBody
    public Object getUsers(HttpServletRequest request) {
        
        String id = request.getParameter("id");   // 注册用户的id
        
        List<Map<String, Object>> list = systemMaintenService.getUsers(id);
        return list;
    }
    
    /**
     * 查询所有角色信息
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/getRoles", method = RequestMethod.GET)
    @ResponseBody
    public Object getRoles(HttpServletRequest request) {
        
        String id = request.getParameter("id");   // 角色id
        
        List<Map<String, Object>> list = systemMaintenService.getRoles(id);
        return list;
    }
    
    /**
     * 查询所有模块信息
     * @param request
     * @return 操作结果
     */
    @RequestMapping(value = "/getModules", method = RequestMethod.GET)
    @ResponseBody
    public Object getModules(HttpServletRequest request) {
        
        String id = request.getParameter("id");   // 模块id
        
        List<Map<String, Object>> list = systemMaintenService.getModules(id);
        return list;
    }
    
    /**
     * 查询用户类型
     * @return 类型集合
     */
    @RequestMapping("/findUserTypes")
    @ResponseBody
    public List<Map<String, Object>> findUserTypes() {
        List<Map<String, Object>> list = systemMaintenService.findUserTypes();
        return list;
    }
    
    /**
     * 查询工作科室列表
     * @return 模块列表
     */
    @RequestMapping(value = "/findWorkRooms")
    @ResponseBody
    public Object findWorkRooms() {
        List<Map<String, Object>> workRooms = systemMaintenService.findWorkRooms();
        
        List<Object> wrList = new ArrayList<Object>();   // 存放一级节点
        List<Map<String, Object>> fatherNodeList = new ArrayList<Map<String,Object>>();   // 存放二级节点(二级节点中包含其子节点)
        
        for (Map<String, Object> map : workRooms) {
            // 获得该菜单节点的节点等级
            int rank = (Integer) map.get("fjb");
            // 判断节点等级，0为一级节点，1为二级节点，2为三级节点
            if (0 == rank) {
                map.put("children", fatherNodeList);
                wrList.add(map);
            } else if (1 == rank) {
                // 为父节点创建一个子节点list集合，用来存放该父节点的子节点
                map.put("children", new ArrayList<Map<String, Object>>());
                fatherNodeList.add(map);
            } else if (2 == rank){  // 当父节点不为空时，表明该节点为子节点，将该子节点添加到对应的父节点中
                for (Map<String, Object> nodeMap : fatherNodeList) {
                    String nodeCode = (String) nodeMap.get("id");
                    String parent = (String) map.get("fparent");
                    if (nodeCode.equals(parent)) {
                        @SuppressWarnings("unchecked")
                        List<Map<String, Object>> childNodeList = (List<Map<String, Object>>) nodeMap.get("children");
                        childNodeList.add(map);
                    }
                }
                
            }
        }
        return wrList;
    }
    
    /**
     * 按用户查询工作科室
     * @return 模块对应菜单
     */
    @RequestMapping(value = "/findUserWorkRooms")
    @ResponseBody
    public Object findUserWorkRooms(HttpServletRequest request) {
        String user =request.getParameter("user");
        List<Map<String, Object>> list = systemMaintenService.findUserWorkRooms(user);
        return list;
    }
    
    /**
     * 按用户查询工作科室
     * 用作科室树展示所需的数据结构
     * @param request
     * @return
     */
    @RequestMapping(value = "/findUserWorkroomTreeData")
    @ResponseBody
    public Object findUserWorkroomTreeData(HttpServletRequest request) {
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        String loginUser = userObject.getFtyyhbh();
        List<Map<String, Object>> workRooms = systemMaintenService.findUserWorkroomsAndQy(loginUser);
        List<Object> wrList = new ArrayList<Object>();   // 存放一级节点
        List<Map<String, Object>> fatherNodeList = new ArrayList<Map<String,Object>>();   // 存放二级节点(二级节点中包含其子节点)
        
        for (Map<String, Object> map : workRooms) {
            // 获得该菜单节点的节点等级
            int rank = (Integer) map.get("fjb");
            // 判断节点等级，0为一级节点，1为二级节点，2为三级节点
            if (0 == rank) {
                map.put("children", fatherNodeList);
                map.put("text", "所有科室");
                wrList.add(map);
            } else if (1 == rank) {
                // 为父节点创建一个子节点list集合，用来存放该父节点的子节点
                map.put("children", new ArrayList<Map<String, Object>>());
                fatherNodeList.add(map);
            } else if (2 == rank){  // 当父节点不为空时，表明该节点为子节点，将该子节点添加到对应的父节点中
                for (Map<String, Object> nodeMap : fatherNodeList) {
                    String nodeCode = (String) nodeMap.get("id");
                    String parent = (String) map.get("fparent");
                    if (nodeCode.equals(parent)) {
                        @SuppressWarnings("unchecked")
                        List<Map<String, Object>> childNodeList = (List<Map<String, Object>>) nodeMap.get("children");
                        childNodeList.add(map);
                    }
                }
                
            }
        }
        return wrList;
    }
    
    /**
     * 按菜单编号查询菜单内容项
     * @param request
     * @return 菜单对应内容项
     */
    @RequestMapping("findMenuContents")
    @ResponseBody
    public Object findMenuContents(HttpServletRequest request) {
        String menuCode = request.getParameter("menuCode");
        
        List<Map<String, Object>> list = systemMaintenService.findMenuContents(menuCode);
        return list;
    }
    
    /**
     * 保存模块对应菜单的内容
     * @param request
     * @return
     */
    @RequestMapping(value = "/saveMenuContents", method = RequestMethod.POST)
    @ResponseBody
    public Object saveMenuContents(HttpServletRequest request) {
        String moduleCode = request.getParameter("moduleCode");  // 权限编号
        String menuCode = request.getParameter("menuCode");  // 菜单编号
        String contentCode = request.getParameter("contentCode");  // 菜单内容01码
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(moduleCode)) {
            params.put("moduleCode", moduleCode);
        }
        if (ConstantsUtils.isNotBank(menuCode)) {
            params.put("menuCode", menuCode);
        }
        if (ConstantsUtils.isNotBank(contentCode)) {
            params.put("contentCode", contentCode);
        }
        int mark = systemMaintenService.saveMenuContents(params);
        
        Map<String, Object> result = new HashMap<String, Object>();
        if (mark > 0) {
            result.put("success", true);
        } else {
            result.put("success", false);
        }
        return result;
    }
    
    /**
     * 查找页面选择的内容
     * @param request
     * @return
     */
    @RequestMapping(value = "/findCheckPC", method = RequestMethod.GET)
    @ResponseBody
    public Object findCheckPC(HttpServletRequest request) {
        String moduleCode = request.getParameter("moduleCode");  // 权限编号
        String menuCode = request.getParameter("menuCode");  // 菜单编号
        
        // 保存参数
        Map<String, Object> params = new HashMap<String, Object>();

        if (ConstantsUtils.isNotBank(moduleCode)) {
            params.put("moduleCode", moduleCode);
        }
        if (ConstantsUtils.isNotBank(menuCode)) {
            params.put("menuCode", menuCode);
        }
        List<Map<String, Object>> result = systemMaintenService.findCheckPC(params);
        return result;
    }
    
    /**
     * 将数据录入操作日志表里面
     */
    @RequestMapping("saveLog")
    public void saveLog(HttpServletRequest request){
        String usercode=(String)request.getSession().getAttribute(GlobalStatic.USER_SESSION_ID);//获取当前用户
        String fprnAndTimes=request.getParameter("fprnAndTimes");//病案号和次数
        String description=request.getParameter("description");//操作描述
        String method=request.getParameter("method");//操作方法
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("usercode", usercode);
        map.put("fprnAndTimes", fprnAndTimes);
        map.put("description", description);
        map.put("method", method);
        systemMaintenService.saveLog(map);
    }
       
    /**
     * 权限设置检查权限名称唯一性
     */
    @RequestMapping("checkModuleName")
    @ResponseBody
    public Object checkModuleName(HttpServletRequest request){
        String moduleName = request.getParameter("moduleName");
        String fsysflag = request.getParameter("fsysflag");
        List list = systemMaintenService.checkModuleName(moduleName,fsysflag);
        return list;
    }
    
    /**
     * 查找系统信息
     * @return
     */
    @RequestMapping("/findSystemInfo")
    @ResponseBody
    public Object findSystemInfo() {
        return systemMaintenService.findSystemInfo();
    }
    
    /**
     * 查询工作病区列表
     * @return 模块列表
     */
    @RequestMapping(value = "/findDistricts")
    @ResponseBody
    public Object findDistricts() {
        List<Map<String, Object>> workRooms = systemMaintenService.findDistricts();
        
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();   // 存放一级节点
        Map<String, Object> childMap = new HashMap<String, Object>();
        childMap.put("id", "n001");
        childMap.put("text", "所有病区");
        childMap.put("children", new ArrayList<Map<String, Object>>());
        list.add(childMap);
        
        for (Map<String, Object> map : workRooms) {
            @SuppressWarnings("unchecked")
            List<Map<String, Object>> childList = (List<Map<String, Object>>) list.get(0).get("children");
            childList.add(map);
        }
        return list;
    }
    
    
    
    /**
     * 查询医院病区
     * @return 科室集合
     */
    @RequestMapping("/findDistrictList")
    @ResponseBody
    public List<Map<String, Object>> findDistrictList() {
        List<Map<String, Object>> list = systemMaintenService.findDistrictList();
        return list;
    }
    
    /**
     * 按用户查询工作病区
     * @return
     */
    @RequestMapping(value = "/findUserDistrict")
    @ResponseBody
    public Object findUserDistrict(HttpServletRequest request) {
        String user =request.getParameter("user");
        List<Map<String, Object>> list = systemMaintenService.findUserDistrict(user);
        return list;
    }
    
    /**
     * 按用户统一工号查找用户工号
     * @return 
     */
    @RequestMapping(value = "/findUserNum", method=RequestMethod.GET)
    @ResponseBody
    public Object findUserNum(HttpServletRequest request) {
    	String number =request.getParameter("number");
    	List<Map<String, Object>> list = systemMaintenService.findUserNum(number);
    	return list;
    }
    
    /**
     * 审核人员配置页面加载审核级别树
     * @return
     */
    
	@RequestMapping("findAuditLevel")
    @ResponseBody
    public Object findAuditLevel(){
    	List<Map<String, Object>> nodeList = new ArrayList<Map<String,Object>>();
    	
    	//查看所有的借阅目的
    	List<Map<String, Object>> parentNode = systemMaintenService.findBorrowPurpose();
    	
    	//遍历父节点
    	for (Map<String, Object> map : parentNode) {
    		
    		//查看所有借阅目的下的审核级别
    		List<Map<String, Object>> chilrenNode = systemMaintenService.findAuditLevel(map.get("id"));
    		
    		if (chilrenNode.size()>0) {
    			map.put("children", chilrenNode);
			}
    		nodeList.add(map);
		}
    	return nodeList;
    }
	
	/**
     * 审核人员配置页面加载所有借阅目的
     * @return
     */
	@RequestMapping("findBorrowPurpose")
    @ResponseBody
    public Object findBorrowPurpose(){
    	return systemMaintenService.findBorrowPurpose();
    }
	
	/**
     * 审核人员配置页面查找所有的审核级别
     * @return
     */
	@RequestMapping("CheckAllLevel")
    @ResponseBody
    public Object CheckAllLevel(HttpServletRequest request){
		Object fjymdid = request.getParameter("fjymdid");
    	return systemMaintenService.findAuditLevel(fjymdid);
    }
	
	/**
     * 审核人员配置页面保存审核级别
     * @return
     */
	@RequestMapping("saveAuditorLevel")
    @ResponseBody
    public Object saveAuditorLevel(HttpServletRequest request){
		String fjymdid = request.getParameter("FJYMDMC");  //获取借阅目的id
		String fshid = request.getParameter("fshid");	   //获取节点代码
		String fname =  request.getParameter("text");	   //获取节点名称
		String fremarks = request.getParameter("fremarks");//获取审核级别备注信息
		Map<String, String> map = new HashMap<String, String>();
		if (ConstantsUtils.isNotBank(fjymdid)) {
			map.put("fjymdid", fjymdid);
		}
		if (ConstantsUtils.isNotBank(fshid)) {
			map.put("fshid", fshid);
		}
		if (ConstantsUtils.isNotBank(fname)) {
			map.put("fname", fname);
		}
		if (ConstantsUtils.isNotBank(fremarks)) {
			map.put("fremarks", fremarks);
		}
    	return systemMaintenService.saveAuditorLevel(map);
    }
	
	/**
     * 审核人员配置页面修改审核级别
     * @return
     */
	@RequestMapping("updateAuditorLevel")
    @ResponseBody
    public Object updateAuditorLevel(HttpServletRequest request){
		String id = request.getParameter("id");  //获取改审核级别id
		String fshid = request.getParameter("fshid");	   //获取节点代码
		String fname =  request.getParameter("text");	   //获取节点名称
		String fremarks = request.getParameter("fremarks");//获取审核级别备注信息
		Map<String, String> map = new HashMap<String, String>();
		if (ConstantsUtils.isNotBank(id)) {
			map.put("id", id);
		}
		if (ConstantsUtils.isNotBank(fshid)) {
			map.put("fshid", fshid);
		}
		if (ConstantsUtils.isNotBank(fname)) {
			map.put("fname", fname);
		}
		if (ConstantsUtils.isNotBank(fremarks)) {
			map.put("fremarks", fremarks);
		}
    	return systemMaintenService.updateAuditorLevel(map);
    }
	
	/**
     * 审核人员配置页面删除审核级别
     * @return
     */
	@RequestMapping("DeleteAuditorLevel")
	@ResponseBody
	public Object DeleteAuditorLevel(HttpServletRequest request){
		String childrenid = request.getParameter("childrenid");//子节点id
		String parentid = request.getParameter("parentid");    //父节点id
		return systemMaintenService.DeleteAuditorLevel(childrenid,parentid);
	}
	
	/**
     * 审核人员配置页面添加用户到审核级别下面
     * @return
     */
	@RequestMapping("addUserToAuditorLevel")
	@ResponseBody
	public Object addUserToAuditorLevel(HttpServletRequest request){
		String childrenid = request.getParameter("childrenid");//子节点id
		String fcodes = request.getParameter("fcodes");    //工号
		return systemMaintenService.addUserToAuditorLevel(childrenid,fcodes);
	}
	
	/**
     * 审核人员配置页面根据节点显示该节点下的所有用户信息
     * @return
     */
	@RequestMapping("loadConfigureUserSelect")
	@ResponseBody
	public PageHelper loadConfigureUserSelect(HttpServletRequest request){
		String type = request.getParameter("type");  //节点类型（子节点、父节点）
		String nodeid = request.getParameter("nodeid");    //子节点id
		int page = Integer.parseInt(request.getParameter("page"));
        int rows = Integer.parseInt(request.getParameter("rows"));
		return systemMaintenService.loadConfigureUserSelect(type,nodeid,page,rows);
	}
	
	/**
	 * 根据用户工号获取用户的所有访问权限设置
	 * return
	 */
	
	@RequestMapping("getUserAccessPermis")
	@ResponseBody
	public PageHelper getUserAccessPermis(HttpServletRequest request){
		String fcode = request.getParameter("fcode");  //用户工号
		int page = Integer.parseInt(request.getParameter("page"));
        int rows = Integer.parseInt(request.getParameter("rows"));
		return systemMaintenService.getUserAccessPermis(fcode,page,rows);
	}
	
	/**
	 * 根据用户工号保存该用户的访问权限
	 * return
	 */
	
	@RequestMapping("saveAccessSettings")
	@ResponseBody
	public boolean saveAccessSettings(HttpServletRequest request){
		String fcode = request.getParameter("fusercode");  //用户工号
		String fqxqsip = request.getParameter("FQXQSIP");  //权限起始ip
        String fqxjsip = request.getParameter("FQXJSIP");  //权限结束ip
		String fstartDate = request.getParameter("FQSRQ");  //起始日期
		String fenddate = request.getParameter("FJSRQ");  //结束日期
		String fxtname = request.getParameter("FXTNAME");  //获取系统名称编码
		Map<String, String> map = new HashMap<String, String>();
		map.put("fcode", fcode);
		map.put("fqxqsip", fqxqsip);
        map.put("fqxjsip", fqxjsip);
		map.put("fstartDate", fstartDate);
		map.put("fendDate", fenddate);
		map.put("fxtname", fxtname);
		return systemMaintenService.saveAccessSettings(map);
	}
	
	/**
	 * 根据权限fid修改一列权限信息
	 * return
	 */
	
	@RequestMapping("updateAccessSettings")
	@ResponseBody
	public boolean updateAccessSettings(HttpServletRequest request){
		String fid = request.getParameter("id");  //权限表id
		String fqxqsip = request.getParameter("FQXQSIP");  //权限起始ip
		String fqxjsip = request.getParameter("FQXJSIP");  //权限结束ip
		String fstartDate = request.getParameter("FQSRQ");  //起始日期
		String fenddate = request.getParameter("FJSRQ");  //结束日期
		String fxtname = request.getParameter("FXTNAME");  //获取系统名称编码
		Map<String, String> map = new HashMap<String, String>();
		map.put("fid", fid);
		map.put("fqxqsip", fqxqsip);
		map.put("fqxjsip", fqxjsip);
		map.put("fstartDate", fstartDate);
		map.put("fendDate", fenddate);
		map.put("fxtname", fxtname);
		return systemMaintenService.updateAccessSettings(map);
	}
	
	
	/**
     * 保存该系统访问权限
     * return
     */
    @RequestMapping("saveSystemSettings")
    @ResponseBody
    public boolean saveSystemSettings(HttpServletRequest request){
        String fqxqsip = request.getParameter("FQXQSIP");  //权限起始ip
        String fqxjsip = request.getParameter("FQXJSIP");  //权限结束ip
        String fstartDate = request.getParameter("FQSRQ");  //起始日期
        String fenddate = request.getParameter("FJSRQ");  //结束日期
        String fxtname = request.getParameter("FXTNAME");  //获取系统名称编码
        Map<String, String> map = new HashMap<String, String>();
        map.put("fqxqsip", fqxqsip);
        map.put("fqxjsip", fqxjsip);
        map.put("fstartDate", fstartDate);
        map.put("fendDate", fenddate);
        map.put("fxtname", fxtname);
        return systemMaintenService.saveSystemSettings(map);
    }
    
    /**
     * 根据id修改系统访问权限
     * return
     */
    @RequestMapping("updateSystemSettings")
    @ResponseBody
    public boolean updateSystemSettings(HttpServletRequest request){
        String fid = request.getParameter("id");  //权限表id
        String fqxqsip = request.getParameter("FQXQSIP");  //权限起始ip
        String fqxjsip = request.getParameter("FQXJSIP");  //权限结束ip
        String fstartDate = request.getParameter("FQSRQ");  //起始日期
        String fenddate = request.getParameter("FJSRQ");  //结束日期
        String fxtname = request.getParameter("FXTNAME");  //获取系统名称编码
        Map<String, String> map = new HashMap<String, String>();
        map.put("fid", fid);
        map.put("fqxqsip", fqxqsip);
        map.put("fqxjsip", fqxjsip);
        map.put("fstartDate", fstartDate);
        map.put("fendDate", fenddate);
        map.put("fxtname", fxtname);
        return systemMaintenService.updateSystemSettings(map);
    }
	
	/**
	 * 根据用户工号获取该用户的访问权限ip地址
	 * return
	 */
	@RequestMapping("getAllUserIp")
	@ResponseBody
	public Object getAllUserIp(HttpServletRequest request){
		String fcode = request.getParameter("fcode");  //用户工号
		String fxtcode = request.getParameter("fxtcode");//获取系统编号
		String fid = request.getParameter("fid");  //获取添加或修列的fid
        String operation = request.getParameter("operation");  //区分操作类型(添加或修改)
		return systemMaintenService.getAllUserIp(fcode, fxtcode, fid, operation);
	}
	
	/**
	 * 根据权限id删除一列权限信息
	 * return
	 */
	@RequestMapping("DeleteAccessAdressById")
	@ResponseBody
	public boolean DeleteAccessAdressById(HttpServletRequest request){
		String fid = request.getParameter("fid");  //用户工号
		return systemMaintenService.DeleteAccessAdressById(fid);
	}
	
	/**
	 * 获取本地局域网所有ip地址和主机名
	 * return
	 */
	@RequestMapping("getAllAdress")
	@ResponseBody
	public Object getAllAdress(){
		return GetLanIp.GetAllLanIp();
	}
	
	/**
	 * 根据权限编号或名称查找权限
	 * return 
	 */
	@RequestMapping("findRoleListByNum")
	@ResponseBody
	public PageHelper findRoleListByNum(HttpServletRequest request){
		String nameNum = request.getParameter("nameNum"); //权限编号或名称
		int page = Integer.parseInt(request.getParameter("page"));
        int rows = Integer.parseInt(request.getParameter("rows"));
        return systemMaintenService.findRoleListByNum(nameNum,page,rows);
	}
	
	/**
	 * 分页获取所有的借阅目的
	 * return 
	 */
	@RequestMapping("getBorrowPurpose")
	@ResponseBody
	public PageHelper getBorrowPurpose(HttpServletRequest request){
		int page = Integer.parseInt(request.getParameter("page"));
        int rows = Integer.parseInt(request.getParameter("rows"));
        return systemMaintenService.getBorrowPurpose(page,rows);
	}
	
	/**
	 * 添加借阅目的
	 * return 
	 */
	@RequestMapping("addBorrowPurpose")
	@ResponseBody
	public Object addBorrowPurpose(HttpServletRequest request){
		String FJYMDBH = request.getParameter("FJYMDBH"); //权限编号或名称
		String FNAME = request.getParameter("FNAME"); //权限编号或名称
		String FTYPE = request.getParameter("FTYPE"); //权限编号或名称
        return systemMaintenService.addBorrowPurpose(FJYMDBH,FNAME,FTYPE);
	}
	
	/**
	 * 修改借阅目的
	 * return 
	 */
	@RequestMapping("editBorrowPurpose")
	@ResponseBody
	public Object editBorrowPurpose(HttpServletRequest request){
		String FID = request.getParameter("FID"); //权限编号或名称
		String FJYMDBH = request.getParameter("FJYMDBH"); //权限编号或名称
		String FNAME = request.getParameter("FNAME"); //权限编号或名称
		String FTYPE = request.getParameter("FTYPE"); //权限编号或名称
        return systemMaintenService.editBorrowPurpose(FID,FJYMDBH,FNAME,FTYPE);
	}
	
	/**
	 * 删除借阅目的
	 * return 
	 */
	@RequestMapping("DeleteBorrowPurpose")
	@ResponseBody
	public Object DeleteBorrowPurpose(HttpServletRequest request){
		String FID = request.getParameter("FID"); //权限编号或名称
        return systemMaintenService.DeleteBorrowPurpose(FID);
	}
	
	/**
	 * 获取所有的借阅目的
	 * return 
	 */
	@RequestMapping("CheckAllBorrowPurpose")
	@ResponseBody
	public Object CheckAllBorrowPurpose(){
        return systemMaintenService.CheckAllBorrowPurpose();
	}
	
	
	/**
	 * 删除个性化病案模板
	 * return 
	 */
	@RequestMapping("deletePersonalizedTemple")
	@ResponseBody
	public Object deletePersonalizedTemple(HttpServletRequest request){
		String fid = request.getParameter("fid");
        return systemMaintenService.deletePersonalizedTemple(fid);
	}
	
	/**
	 * 获取树数据
	 * return 
	 */
	@RequestMapping("getTreeData")
	@ResponseBody
	public Object getTreeData(HttpServletRequest request){
		String fid = request.getParameter("fid");
        return systemMaintenService.getTreeData(fid);
	}
	
	/**
	 * 保存用户组浏览权限设置信息
	 * return 
	 */
	@RequestMapping("saveAccessSet")
	@ResponseBody
	public Object saveAccessSet(HttpServletRequest request){
		String time = "null";
		String groupCode = request.getParameter("groupCode"); //获取用户组编号
		int right = Integer.parseInt(request.getParameter("right"));  //获取权限类型
		int timeUnit = Integer.parseInt(request.getParameter("FLLQXSJDW")); //获取浏览时间时间单位
		if (timeUnit != 3) {
			time = request.getParameter("FLLQXSJ"); //获取权限浏览时间
		}
        return systemMaintenService.saveAccessSet(groupCode,right,time,timeUnit);
	}
	
	/**
	 * 根据用户组编号获取用户组浏览权限设置信息
	 * return 
	 */
	@RequestMapping("getAccessSet")
	@ResponseBody
	public Object getAccessSet(HttpServletRequest request){
		String groupCode = request.getParameter("groupCode"); //获取用户组编号
        return systemMaintenService.getAccessSet(groupCode);
	}
	
	/**
	 * 根据用户组编号获取用户组图片分类模板
	 * return 
	 */
	@RequestMapping("getImgTemple")
	@ResponseBody
	public Object getImgTemple(HttpServletRequest request){
		String groupCode = request.getParameter("fcode"); //获取用户组编号
        return systemMaintenService.getImgTemple(groupCode);
	}
	
	/**
	 * 根据用户组编号获取用户组字段分类模板
	 * return 
	 */
	@RequestMapping("getFieldTemple")
	@ResponseBody
	public Object getFieldTemple(HttpServletRequest request){
		String groupCode = request.getParameter("fcode"); //获取用户组编号
        return systemMaintenService.getFieldTemple(groupCode);
	}
	
	/**
	 * 根据图片分类模板id加载图片分类权限(阅读、导出、打印)明细表
	 * return 
	 */
	@RequestMapping("findImgTemoleDetail")
	@ResponseBody
	public Object findImgTemoleDetail(HttpServletRequest request){
		String fid = request.getParameter("fid"); //获取用户组编号
        return systemMaintenService.findImgTemoleDetail(fid);
	}
	
	/**
	 * 根据用户组保存图片分类模板
	 * return 
	 */
	@RequestMapping("saveImgTemple")
	@ResponseBody
	public Object saveImgTemple(HttpServletRequest request){
		String name = request.getParameter("name"); //图片分类名称
		String ids = request.getParameter("ids"); //获取图片分类fid字符串
		String fcode = request.getParameter("fcode"); //获取用户组编号
		String value = request.getParameter("value"); //获取图片分类模板阅读 打印和导出权限值
		String imgid = request.getParameter("imgid"); //获取图片分类模板id
		
		Map<String, String> map = new HashMap<String, String>();
		map.put("name", name);
		map.put("ids", ids);
		map.put("fcode", fcode);
		map.put("value", value);
		map.put("imgid", imgid);
		
        return systemMaintenService.saveImgTemple(map);
	}
	
	/**
	 * 获取字段信息树
	 * return 
	 */
	@RequestMapping("getFieldTree")
	@ResponseBody
	public Object getFieldTree(HttpServletRequest request){
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		Map<String, Object> map = new HashMap<String, Object>();
		List<Map<String, Object>> Nodelist = systemMaintenService.getFieldTree();
		map.put("id", "001");
		map.put("text", "全部");
		map.put("children", Nodelist);
		list.add(map);
        return list;
	}
	
	/**
	 * 保存用户组字段分类模板
	 * return 
	 */
	@RequestMapping("saveFieldTemple")
	@ResponseBody
	public Object saveFieldTemple(HttpServletRequest request){
		String name = request.getParameter("name"); //字段分类模板名称
		String fcode = request.getParameter("fcode"); //获取用户组编号
		String fieldMbId = request.getParameter("fieldMbId"); //获取字段分类模板   id
		String fieldCode = request.getParameter("fieldCode"); //获取字段分类模板字段   编码   字符串
		String fieldName = request.getParameter("fieldName"); //获取字段分类模板字段   名称   字符串
		
		Map<String, String> map = new HashMap<String, String>();
		map.put("name", name);
		map.put("fieldMbId", fieldMbId);
		map.put("fcode", fcode);
		map.put("fieldCode", fieldCode);
		map.put("fieldName", fieldName);
		
        return systemMaintenService.saveFieldTemple(map);
	}
	
	/**
	 * 根据字段分类模板id加载该字段模板下的字段信息
	 * return 
	 */
	@RequestMapping("findFieldTemoleDetail")
	@ResponseBody
	public Object findFieldTemoleDetail(HttpServletRequest request){
		String id = request.getParameter("id"); //获取用户组编号
        return systemMaintenService.findFieldTemoleDetail(id);
	}
	
	/**
	 * 修改图片分类模板系统默认设置项
	 * return 
	 */
	@RequestMapping("updateImgMbDefault")
	@ResponseBody
	public void updateImgMbDefault(HttpServletRequest request){
		String id = request.getParameter("id"); //图片分类模板id
		String Groupfcode = request.getParameter("Groupfcode"); //获取用户组编号
        systemMaintenService.updateImgMbDefault(id,Groupfcode);
	}
	
	/**
	 * 修改字段分类模板系统默认设置项
	 * return 
	 */
	@RequestMapping("updateFiledMbDefault")
	@ResponseBody
	public void updateFiledMbDefault(HttpServletRequest request){
		String Groupfcode = request.getParameter("Groupfcode"); //获取用户组编号
		String id = request.getParameter("id"); //字段分类模板id
        systemMaintenService.updateFiledMbDefault(id,Groupfcode);
	}
	
	/**
	 * 根据字段名称模糊匹配字段
	 * return 
	 */
	@RequestMapping("searchFieldByName")
	@ResponseBody
	public Object searchFieldByName(HttpServletRequest request){
		String value = request.getParameter("value"); //获取用户组编号
        return systemMaintenService.searchFieldByName(value);
	}
	
	/**
     * 加载所有系统权限设置
     * return 
     */
    @RequestMapping("loadSystemAccessAdr")
    @ResponseBody
    public PageHelper loadSystemAccessAdr(HttpServletRequest request){
        int page = Integer.parseInt(request.getParameter("page"));
        int rows = Integer.parseInt(request.getParameter("rows"));
        return systemMaintenService.loadSystemAccessAdr(page,rows);
    }
    
    /**
     * 根据系统类型访编号访问权限ip地址
     * return
     */
    @RequestMapping("getAllSystemIp")
    @ResponseBody
    public Object getAllSystemIp(HttpServletRequest request){
        String fcode = request.getParameter("fcode");  //系统类型编号
        String fid = request.getParameter("fid");  //获取添加或修列的fid
        String operation = request.getParameter("operation");  //区分操作类型(添加或修改)
        return systemMaintenService.getAllSystemIp(fcode, fid, operation);
    }
    
    /**
     * 根据借阅类型id分页加载该借阅类型下所有原因
     * return 
     */
    @RequestMapping("loadReasonsApplitData")
    @ResponseBody
    public PageHelper loadReasonsApplitData(HttpServletRequest request){
        int page = Integer.parseInt(request.getParameter("page"));
        int rows = Integer.parseInt(request.getParameter("rows"));
        String fjymdid = request.getParameter("fjymdid");  //借阅类型id
        return systemMaintenService.loadReasonsApplitData(fjymdid, page, rows);
    }
    
    /**
     * 根据借阅类型id添加借阅原因
     * return 
     */
    @RequestMapping("addReasonsApplit")
    @ResponseBody
    public Object addReasonsApplit(HttpServletRequest request){
        String fjymdid = request.getParameter("fjymdid");  //借阅类型id
        String fjymdyymc = request.getParameter("FJYMDYYMC");  //借阅原因名称
        String fjymdyybh = request.getParameter("FJYMDYYBH");  //借阅原因编号
        return systemMaintenService.addReasonsApplit(fjymdid, fjymdyymc, fjymdyybh);
    }
    
    /**
     * 根据借阅原因id修改借阅原因
     * return 
     */
    @RequestMapping("editReasonsApplit")
    @ResponseBody
    public Object editReasonsApplit(HttpServletRequest request){
        String fid = request.getParameter("fid");  //借阅原因id
        String fjymdyymc = request.getParameter("FJYMDYYMC");  //借阅原因名称
        String fjymdyybh = request.getParameter("FJYMDYYBH");  //借阅原因编号
        return systemMaintenService.editReasonsApplit(fid, fjymdyymc, fjymdyybh);
    }
    
    /**
     * 加载借阅类型下所有借阅原因
     * return 
     */
    @RequestMapping("CheckAllReasonsApplit")
    @ResponseBody
    public Object CheckAllReasonsApplit(HttpServletRequest request){
        String fjymdid = request.getParameter("fjymdid");  //借阅类型id
        return systemMaintenService.CheckAllReasonsApplit(fjymdid);
    }
    
    /**
     * 根据id删除借阅类型下借阅原因
     * return 
     */
    @RequestMapping("DeleteReasonsApplit")
    @ResponseBody
    public Object DeleteReasonsApplit(HttpServletRequest request){
        String fid = request.getParameter("fid"); //权限编号或名称
        return systemMaintenService.DeleteReasonsApplit(fid);
    }
    
    /**
     * 加载所有申请类型
     * return 
     */
    @RequestMapping("loadApplyType")
    @ResponseBody
    public Object loadApplyType(HttpServletRequest request){
        return systemMaintenService.loadApplyType();
    }
    
    /**
     * 从用户表中加载所有用户信息
     * return 
     */
    @RequestMapping("loadUsers")
    @ResponseBody
    public Object loadUsers(HttpServletRequest request){
        return systemMaintenService.loadUsers();
    }
    
    /**
     * 根据申请分类id加载审核级别
     * return 
     */
    @RequestMapping("loadExamineLevel")
    @ResponseBody
    public Object loadExamineLevel(HttpServletRequest request){
        String fid = request.getParameter("fid"); //权限编号或名称
        return systemMaintenService.loadExamineLevel(fid);
    }
    
    /**
     * 根据审核级别ID加载审核人员设置
     * return 
     */
    @RequestMapping("loadExaminePersion")
    @ResponseBody
    public Object loadExaminePersion(HttpServletRequest request){
        String fid = request.getParameter("fid"); //权限编号或名称
        return systemMaintenService.loadExaminePersion(fid);
    }
    
    /**
     * 添加或修改审核级别，判断是否存在相同的名称
     * return 
     */
    @RequestMapping("checkSpName")
    @ResponseBody
    public Object checkSpName(HttpServletRequest request){
        String type = request.getParameter("type");  //0 添加   1 修改
        String newName = request.getParameter("newName");  //修改或添加的名称
        String oldName = request.getParameter("oldName");  //修改前的名称
        return systemMaintenService.checkSpName(type, newName, oldName);
    }
    
    /**
     * 添加审核级别
     * return 
     */
    @RequestMapping("addExamineLevel")
    @ResponseBody
    public Object addExamineLevel(HttpServletRequest request){
        String examineName = request.getParameter("examineName");  //审批名称
        String applyTypeId = request.getParameter("applyTypeId");  //申请分类id
        return systemMaintenService.addExamineLevel(examineName, applyTypeId);
    }
    
    /**
     * 修改审核级别
     * return 
     */
    @RequestMapping("editExamineLevel")
    @ResponseBody
    public Object editExamineLevel(HttpServletRequest request){
        String examineName = request.getParameter("examineName");  //新审批名称
        String fid = request.getParameter("fid");  //审核级别id
        return systemMaintenService.editExamineLevel(examineName, fid);
    }
    
    /**
     * 根据两者id交换数据的fpx号
     * return 
     */
    @RequestMapping("ExchangeFpx")
    @ResponseBody
    public void ExchangeFpx(HttpServletRequest request){
        String currentId = request.getParameter("currentId");  //当前行id
        String currentFpx = request.getParameter("currentFpx");  //当前行fpx号
        String nextId = request.getParameter("nextId");  //交换行id
        String nextFpx = request.getParameter("nextFpx");  //交换行fpx号
        
        systemMaintenService.ExchangeFpx(currentId, currentFpx, nextId, nextFpx);
    }
    
    /**
     * 根据审核级别ID删除该审批级别
     * return 
     */
    @RequestMapping("deleteExamineLevel")
    @ResponseBody
    public Object deleteExamineLevel(HttpServletRequest request){
        String fid = request.getParameter("fid"); //审批级别id
        return systemMaintenService.deleteExamineLevel(fid);
    }
    
    /**
     * 根据审批级别添加相应的审批人员
     * return 
     */
    @RequestMapping("addExaminePersion")
    @ResponseBody
    public Object addExaminePersion(HttpServletRequest request){
        String fspjbid = request.getParameter("fspjbid");  //审批级别id
        String persionCode = request.getParameter("persionCode");  //审批人员工号
        String fspks = request.getParameter("fspks");  //审批科室科号
        String examineKsName = request.getParameter("examineKsName"); //审批科室名称
        return systemMaintenService.addExaminePersion(fspjbid, persionCode, fspks, examineKsName);
    }
    
    /**
     * 根据审批人员的id修改申请该审批人员的信息
     * return 
     */
    @RequestMapping("editExaminePersion")
    @ResponseBody
    public Object editExaminePersion(HttpServletRequest request){
        String fid = request.getParameter("fid");  //审批人员id
        String persionCode = request.getParameter("persionCode");  //审批人员工号
        String fspks = request.getParameter("fspks");  //审批科室
        String examineKsName = request.getParameter("examineKsName"); //审批科室名称
        return systemMaintenService.editExaminePersion(fid, persionCode, fspks, examineKsName);
    }
    
    /**
     * 根据审批人员id删除信息
     * return 
     */
    @RequestMapping("deleteExaminePersion")
    @ResponseBody
    public Object deleteExaminePersion(HttpServletRequest request){
        String fid = request.getParameter("fid");  //审批人员id
        return systemMaintenService.deleteExaminePersion(fid);
    }
    
    /**
     * 根据图片分离模板id获取所有个性化病案模板
     * return 
     */
    @RequestMapping("loadUserImgDataByTemp")
    @ResponseBody
    public Object loadUserImgDataByTemp(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        String tempid = request.getParameter("tempid");  //图片分类模板id
        return systemMaintenService.loadUserImgDataByTemp(userObject, tempid);
    }
    
    /**
     * 获取所有个性化图片模板
     * return 
     */
    @RequestMapping("getUserImgShowTemple")
    @ResponseBody
    public Object getUserImgShowTemple(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        return systemMaintenService.getUserImgShowTemple(userObject);
    }
    
    /**
     * 获取所有个性化字段模板
     * return 
     */
    @RequestMapping("getUserFieldShowTemple")
    @ResponseBody
    public Object getUserFieldShowTemple(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        return systemMaintenService.getUserFieldShowTemple(userObject);
    }
    
    /**
     * 保存个性化设置
     * return 
     */
    @RequestMapping("saveInAccessSet")
    @ResponseBody
    public Object saveInAccessSet(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String, Object> map = new HashMap<String, Object>();
        
        String imgShowMode = request.getParameter("SHOWMODE"); //图片显示方式  1、适合宽度  2、适合高度  3、适合大小 4、实际大小
        String imgShowcolor = request.getParameter("color");   //图片默认显示颜色   0、黑白 1、彩色
        String showNumberRow = request.getParameter("NUMBERROW");  //字段显示行数
        String printPaper = request.getParameter("PRINTPAPER");    //显示纸张  1:A4  2:A3  3:A5 4:A4
        
        map.put("imgShowMode", Integer.parseInt(imgShowMode));
        map.put("imgShowcolor", Integer.parseInt(imgShowcolor));
        map.put("showNumberRow", Integer.parseInt(showNumberRow));
        map.put("printPaper", Integer.parseInt(printPaper));
        map.put("fusercode", userObject.getFcode());
        
        return systemMaintenService.saveInAccessSet(map);
    }
    
    /**
     * 获取系统默认字段信息树
     * return 
     */
    @RequestMapping("getFieldInTree")
    @ResponseBody
    public Object getFieldInTree(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        
        List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
        Map<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> Nodelist = systemMaintenService.getFieldInTree(userObject.getFgroupcode());
        map.put("id", "001");
        map.put("text", "全部");
        map.put("children", Nodelist);
        list.add(map);
        return list;
    }
    
    /**
     * 获取用户个性化设置
     * return 
     */
    @RequestMapping("getInAccessSet")
    @ResponseBody
    public Object getInAccessSet(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        return systemMaintenService.getInAccessSet(userObject.getFcode());
    }
    
    /**
     * 保存用户个性化字段模板main
     * return 
     */
    @RequestMapping("saveInFieldTemp")
    @ResponseBody
    public Object saveInFieldTemp(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        String name = request.getParameter("name"); //获取模板名称
        String mbId = request.getParameter("mbId"); //获取模板id
        
        Map<String, Object> map = new HashMap<String, Object>();
        
        map.put("fcode", userObject.getFcode());
        map.put("name", name);
        map.put("mbId", mbId);
        return systemMaintenService.saveInFieldTemp(map);
    }
    
    /**
     * 保存用户个性化字段分类模板字段信息
     * return 
     */
    @RequestMapping("saveInFieldTemple")
    @ResponseBody
    public Object saveInFieldTemple(HttpServletRequest request){
        String fieldMbId = request.getParameter("mbid"); //获取字段分类模板   id
        String fieldCode = request.getParameter("fieldCode"); //获取字段分类模板字段   编码   字符串
        String fieldName = request.getParameter("fieldName"); //获取字段分类模板字段   名称   字符串
        
        Map<String, String> map = new HashMap<String, String>();
        map.put("fieldMbId", fieldMbId);
        map.put("fieldCode", fieldCode);
        map.put("fieldName", fieldName);
        
        return systemMaintenService.saveInFieldTemple(map);
    }
    
    /**
     * 根据字段分类模板id同步加载字段信息
     * return 
     */
    @RequestMapping("loadUserFieldDataByTemp")
    @ResponseBody
    public Object loadUserFieldDataByTemp(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        int mbid = Integer.parseInt(request.getParameter("mbid"));  //获取字段模板id
        return systemMaintenService.loadUserFieldDataByTemp(mbid,userObject);
    }
    
    /**
     * 根据字段分类模板id删除该模板
     * return 
     */
    @RequestMapping("deleteFieldTemple")
    @ResponseBody
    public Object deleteFieldTemple(HttpServletRequest request){
        int mbid = Integer.parseInt(request.getParameter("fid"));  //获取字段模板id
        return systemMaintenService.deleteFieldTemple(mbid);
    }
    
    /**
     * 保存用户个性化图片模板main
     * return 
     */
    @RequestMapping("saveInImgTemp")
    @ResponseBody
    public Object saveInImgTemp(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        String name = request.getParameter("name"); //获取模板名称
        String mbId = request.getParameter("mbId"); //获取模板id
        
        Map<String, Object> map = new HashMap<String, Object>();
        
        map.put("fcode", userObject.getFcode());
        map.put("name", name);
        map.put("mbId", mbId);
        return systemMaintenService.saveInImgTemp(map);
    }
    
    /**
     * 根据图片分类模板id删除该模板
     * return 
     */
    @RequestMapping("deleteInImgTemple")
    @ResponseBody
    public Object deleteInImgTemple(HttpServletRequest request){
        int mbid = Integer.parseInt(request.getParameter("fid"));  //获取字段模板id
        return systemMaintenService.deleteInImgTemple(mbid);
    }
    
    /**
     * 保存用户个性化图片模板detail
     * return 
     */
    @RequestMapping("saveInImgTemple")
    @ResponseBody
    public Object saveInImgTemple(HttpServletRequest request){
        
        int mbid = Integer.parseInt(request.getParameter("mbid"));  //获取图片模板id
        String tmbidStr = request.getParameter("tmbidStr"); //图片分类 id字符串
        
        return systemMaintenService.saveInImgTemple(mbid, tmbidStr);
    }
    
    /**
     * 系统管理-获取系统
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/getSystem")
    @ResponseBody
    public Object getSystem(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-增加系统
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/addSystem")
    @ResponseBody
    public Object addSystem(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-编辑系统
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/editSystem")
    @ResponseBody
    public Object editSystem(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-删除系统
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/deleteSystem")
    @ResponseBody
    public Object deleteSystem(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-根据系统取菜单
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/menu/getMenuBySys")
    @ResponseBody
    public Object getMenuBySys(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-菜单管理-新增菜单
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/menu/addMenu")
    @ResponseBody
    public Object addMenu(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-菜单管理-编辑菜单
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/menu/editMenu")
    @ResponseBody
    public Object editMenu(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-菜单管理-删除菜单
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/menu/deleteMenu")
    @ResponseBody
    public Object deleteMenu(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-功能菜单-取功能菜单
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/menu/getFunctionByMenu")
    @ResponseBody
    public Object getFunctionByMenu(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-功能菜单-增加
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/menu/addFunction")
    @ResponseBody
    public Object addFunction(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-功能菜单-编辑
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/menu/editFunction")
    @ResponseBody
    public Object editFunction(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
    
    /**
     * 系统管理-功能菜单-删除
     * @author [lv tang wei]
     * Describe:
     * @param request
     * @return
     * [2017年6月30日]
     */
    @RequestMapping("system/menu/deleteFunction")
    @ResponseBody
    public Object deleteFunction(HttpServletRequest request){
        Tsysuser userObject = (Tsysuser) request.getSession().getAttribute(GlobalStatic.USER_SESSION_OBJECT);
        Map<String,Object> param=this.getParameterMap(request);
        return null;
    }
}
